package com.ipet.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.ipet.common.utils.PageUtils;
import com.ipet.common.utils.R;
import com.ipet.modules.sys.entity.PetOperationEntity;
import com.ipet.modules.sys.service.PetOperationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 手术管理
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-04-23 15:39:03
 */
@RestController
@RequestMapping("sys/petoperation")
public class PetOperationController {
    @Autowired
    private PetOperationService petOperationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:petoperation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = petOperationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:petoperation:info")
    public R info(@PathVariable("id") Integer id){
			PetOperationEntity petOperation = petOperationService.selectById(id);

        return R.ok().put("petOperation", petOperation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:petoperation:save")
    public R save(@RequestBody PetOperationEntity petOperation){
        petOperation.setCreateTime(new Date());
			petOperationService.insert(petOperation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:petoperation:update")
    public R update(@RequestBody PetOperationEntity petOperation){
			petOperationService.updateById(petOperation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:petoperation:delete")
    public R delete(@RequestBody Integer[] ids){
			petOperationService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
